const path = require('path')
const { defineConfig } = require('@vue/cli-service')
const { usePrerender } = require('./build/usePrerender')

module.exports = defineConfig({
  transpileDependencies: true,

  outputDir: path.resolve(__dirname, `${process.env.VUE_APP_OUTDIR || 'dist'}`),

  publicPath: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_URL : '/',

  configureWebpack(config) {
    config.resolve.alias['@'] = path.resolve(__dirname, 'src')

    if (process.env.NODE_ENV !== 'production') {
      return
    }

    return {
      plugins: [
        usePrerender()
      ]
    }
  },

  devServer: {
    open: true,
    host: 'localhost',
    port: 9124,
    https: false
  },

  // pluginOptions: {
  //   'style-resources-loader': {
  //     preProcessor: 'less',
  //     patterns: [
  //       path.resolve(__dirname, './src/assets/css/uni.less'),
  //       path.resolve(__dirname, './src/assets/css/color.less')
  //     ]
  //   }
  // },

})
